#include <stdio.h>
#include <stdlib.h>
typedef struct point
{
    double x, y;
};

double caculate_area(point *sets, int setsSize)
{
    double area = 0;
    for (int i = 0; i < setsSize - 1; i++)
    {
        double x1, x2, y1, y2;
        x1 = sets[i].x, y1 = sets[i].y;
        x2 = sets[i + 1].x, y2 = sets[i + 1].y;
        area += (x2 * y1 - x1 * y2);
    }

    return area / 2;
}

int main()
{
    /*******************code*******************/
    // double x[] = {4, 4, 8, 8, -4, -4, 4};
    // double y[] = {6, -4, -4, -8, -8, 6, 6};
    double x[] = {3, 5, 12, 9, 5, 3};
    double y[] = {4, 11, 8, 5, 6, 4};
    point sets[7];
    int setsSize = 6;
    for (int i = 0; i < setsSize; i++)
    {
        sets[i].x = x[i], sets[i].y = y[i];
    }
    double area = caculate_area(sets, setsSize);
    printf("%lf", area);
    /******************************************/
    fflush(stdin);

    printf("\n\n****************************\n");
    printf("Press Enter key to continue\n");
    getchar();
    return 0;
    /******************************************/
}
